﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace AnimacaoBoneca
{
    
    public class Game1 : Microsoft.Xna.Framework.Game
    {

        # region Variáveis e objetos
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;

        Texture2D NicoleTX;
        Texture2D FlurryTX;
        Texture2D JenyTX;
        Texture2D NewtonTX;

        KeyboardState teclado_atual, teclado_anterior;
        int Tela;

        Nicole nicole;
        Flurry flurry;
        Jeny jeny;
        Newton newton;

        #endregion 



        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

        protected override void Initialize()
        {
            graphics.PreferredBackBufferHeight = 300;
            graphics.PreferredBackBufferWidth = 1000;
            graphics.ApplyChanges();


            Tela = 1;

            base.Initialize();
        }

        protected override void LoadContent()
        {

            spriteBatch = new SpriteBatch(GraphicsDevice);

            #region Carregar imagens
            NicoleTX = Content.Load<Texture2D>("Nicole");
            FlurryTX = Content.Load<Texture2D>("Flurry");
            JenyTX = Content.Load<Texture2D>("Jeny");
            NewtonTX= Content.Load<Texture2D>("Newton");
            #endregion 


            # region Estanciando objetos de classe
            nicole = new Nicole(new Vector2(0, 0), 300, 1000, NicoleTX, new Rectangle(0, 0, 300, 250));
            flurry = new Flurry(new Vector2(0, 0), 300, 1000, FlurryTX, new Rectangle(0, 0, 300, 250));
            jeny = new Jeny (new Vector2(0, 0), 300, 1000, JenyTX, new Rectangle(0, 0, 300, 250));
            newton = new Newton(new Vector2(0, 0), 300, 1000,NewtonTX, new Rectangle(0, 0, 300, 250));
            #endregion 




        }


        protected override void UnloadContent()
        {

        }


        protected override void Update(GameTime gameTime)
        {
             //Exit(); this.Exit();


            teclado_atual = Keyboard.GetState();
            MudancaTela();
            teclado_anterior = teclado_atual;
 


            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            


            #region Funções desenhar na ela
            spriteBatch.Begin();
            switch (Tela)
            {
                case 1:
                    nicole.DesenhoTela1(spriteBatch);
                    break;
                case 2:
                    nicole.DesenhoTela2(spriteBatch);
                    break;
                case 3:
                    nicole.DesenhoTela3(spriteBatch);
                    break;
                case 4:
                    nicole.DesenhoTela4(spriteBatch);
                    break;
                case 5:
                    flurry.DesenhoTela1(spriteBatch);
                    break;
                case 6:
                    flurry.DesenhoTela2(spriteBatch);
                    break;
                case 7:
                    flurry.DesenhoTela3(spriteBatch);
                    break;
                case 8:
                    flurry.DesenhoTela4(spriteBatch);
                    break;
                case 9:
                    jeny.DesenhoTela1(spriteBatch);
                    break;
                case 10:
                    jeny.DesenhoTela2(spriteBatch);
                    break;
                case 11:
                    jeny.DesenhoTela3(spriteBatch);
                    break;
                case 12:
                    jeny.DesenhoTela4(spriteBatch);
                    break;
                case 13:
                    newton.DesenhoTela1(spriteBatch);
                    break;
                case 14:
                    newton.DesenhoTela2(spriteBatch);
                    break;
                case 15:
                    newton.DesenhoTela3(spriteBatch);
                    break;
                case 16:
                    newton.DesenhoTela4(spriteBatch);
                    break;
            }

            spriteBatch.End();

            #endregion 

            base.Draw(gameTime);
        }

        #region Mudança da tela através do teclado
        public void MudancaTela()
        {
            if (teclado_atual.IsKeyDown(Keys.Left)
                && !teclado_anterior.IsKeyDown(Keys.Left))
            {
                Tela--;

                if (Tela < 1)
                {
                    Tela = 1;
                }


            }

            if (teclado_atual.IsKeyDown(Keys.Right)
                && !teclado_anterior.IsKeyDown(Keys.Right))
            {
                Tela++;


                if (Tela > 16)
                {
                    Tela = 16;
                }
            }

        }

        #endregion 

    }
}
